//package com.generator.listener.support;
//
//import com.generator.constant.NodePath;
//import com.generator.controller.LeaderService;
//import com.generator.listener.NodeListener;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.util.Collections;
//import java.util.List;
//
//@Slf4j
//@Service
//public class ClusterLeaderChangeListener implements NodeListener {
//
//    @Resource
//    private LeaderService leaderService;
//
//    @Override
//    public List<String> getPath() {
//        return Collections.singletonList(NodePath.CONTROLLER_PATH);
//    }
//
//    @Override
//    public void onDelete(String path) {
//        log.info("[ClusterLeaderChangeListener-NodeListener] The cluster leader changed,will trigger re-elect leader.");
//
//        if(!NodePath.CONTROLLER_PATH.equals(path)) {
//            return;
//        }
//        // 重新选举leader
//        leaderService.electLeader();
//    }
//
//    @Override
//    public void onDataChange(String path, String currentData) {
//        // nothing to do
//    }
//}
